/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package credit.paysystem;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
import mx.its.LnLocal.UsuarioLnLocal;
import mx.its.ln.UsuarioLN;

/**
 * FXML Controller class
 *
 * @author Grnmnd
 */
public class LogInController implements Initializable {

    @FXML
    TextField usuario;
    @FXML
    TextField pass;
    @FXML
    private Pane LogIn;

    /**
     * Initializes the controller class.
     */
    @FXML
    public void siono() throws IOException {
        UsuarioLnLocal ull = new UsuarioLN();
        if (ull.getPorNoControl(usuario.getText()) != null) {
            if (ull.getPorNoControl(usuario.getText()).getContrasenia().equals(pass.getText())) {
                MovimientosController.Autoriza = ull.getPorNoControl(usuario.getText());
                CobroController.Autoriza = ull.getPorNoControl(usuario.getText());
                UsuariosController.cs = ull.getPorNoControl(usuario.getText());
                PrincipalController.Autoriza=ull.getPorNoControl(usuario.getText());
                Stage stage = new Stage();
                Parent root = FXMLLoader.load(getClass().getResource("Principal.fxml"));
                Scene scene = new Scene(root);
                stage.setScene(scene);
                stage.show();
                LogIn.getScene().getWindow().hide();

            } else {
                JOptionPane.showMessageDialog(null, "Contraseña Incorrecta");
            }
        } else {
            JOptionPane.showMessageDialog(null, "Usuario Incorrecto");
        }
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
    }
}
